package com.aa.activity;

import com.aa.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.TextView;

public class AASayActivity extends Activity {

	private RadioButton rbtnComposite;
	private RadioButton rbtnLifle;
	private RadioButton rbtnInspiration;
	private RadioButton rbtnRecreation;
	private RadioButton rbtnWellknownSay;
	private Button mbtnTitle;
	private TextView mtvCenterTitle;
	@Override
	protected void onCreate(Bundle savedInstanceState) {		
		super.onCreate(savedInstanceState);		
		setContentView(R.layout.aa_say);
		initView();
		initListener();
	}
	
	private void initView(){
		rbtnComposite = (RadioButton)findViewById(R.id.rbtn_aa_composite);
		rbtnLifle = (RadioButton)findViewById(R.id.rbtn_aa_life);
		rbtnInspiration = (RadioButton)findViewById(R.id.rbtn_aa_inspiration);
		rbtnRecreation = (RadioButton)findViewById(R.id.rbtn_aa_recreation);
		rbtnWellknownSay = (RadioButton)findViewById(R.id.rbtn_aa_wellknown_saying);
		
		mtvCenterTitle = (TextView)findViewById(R.id.app_title_center);
		mtvCenterTitle.setText(R.string.aa_say);
		
		mbtnTitle = (Button)findViewById(R.id.title_btn1);
		mbtnTitle.setVisibility(View.VISIBLE);
		mbtnTitle.setText(R.string.app_back_tip);
		mbtnTitle.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				finish();
				
			}
		});
	}
	private void initListener(){
		rbtnComposite.setOnClickListener(new OnrbtnClickListener());
		rbtnLifle.setOnClickListener(new OnrbtnClickListener());
		rbtnInspiration.setOnClickListener(new OnrbtnClickListener());
		rbtnRecreation.setOnClickListener(new OnrbtnClickListener());
		rbtnWellknownSay.setOnClickListener(new OnrbtnClickListener());
	
	}
	private void cleanAllTextColor(){
		rbtnComposite.setTextColor(0xff000000);
		rbtnLifle.setTextColor(0xff000000);
		rbtnInspiration.setTextColor(0xff000000);
		rbtnRecreation.setTextColor(0xff000000);
		rbtnWellknownSay.setTextColor(0xff000000);						
	}
	private void setAllRadioButtonFalse(){
		rbtnComposite.setChecked(false);
		rbtnLifle.setChecked(false);
		rbtnInspiration.setChecked(false);
		rbtnRecreation.setChecked(false);
		rbtnWellknownSay.setChecked(false);
		
	}
	private class OnrbtnClickListener implements OnClickListener{

		
		@Override
		public void onClick(View v) {
			cleanAllTextColor();
			setAllRadioButtonFalse();
			switch (v.getId()) {
			case R.id.rbtn_aa_composite:
				rbtnComposite.setTextColor(0xff48cdff);
			
				break;
			case R.id.rbtn_aa_life:
				rbtnLifle.setTextColor(0xff48cdff);
				
				break;
			case R.id.rbtn_aa_inspiration:
				rbtnInspiration.setTextColor(0xff48cdff);
				
				break;
			case R.id.rbtn_aa_recreation:
				rbtnRecreation.setTextColor(0xff48cdff);				
				break;
			case R.id.rbtn_aa_wellknown_saying:
				rbtnWellknownSay.setTextColor(0xff48cdff);
			
		
			
			}
		}
		
	}

}
